<?php $this->headScript()->appendFile($this->JS_PATH . 'site.js'); ?>
<?php $this->headScript()->appendFile($this->JS_PATH . 'bootstrap.datepicker.js'); ?>

<div id="site-listing"></div>
<div class="container-fluid">
<div id="pad-wrapper" class="form-page">
    <form role="form" id="site-form" name="site-form"  enctype="multipart/form-data"  action="" method="post">
                
        <div class="row-fluid form-wrapper">
        <!-- left column -->
        <div class="span column span5 ">
            <?php if ($this->successmessage != ''): ?>
                <div class="alert alert-success">
                    <i class="icon-ok-sign"></i> <?php echo $this->successmessage; ?>
                </div>
            <?php endif; ?>
            <?php if (count($this->errorMessageArray) > 0): ?>
                <div class="alert alert-error">
                    <?php foreach ($this->errorMessageArray as $erroValue): ?>

                        <div class="text-left">
                            <i class="icon-remove-sign"></i>
                            <?php echo $erroValue; ?>
                        </div>
                    <?php endforeach; ?>
                </div>
            <?php endif; ?>
             <h3><?php echo $this->mode;?> <?php echo $this->translate("site_header"); ?></h3>
             <br />
            <div class="field-box">
                    <label><?php echo $this->translate("site_frm_name"); ?><span class="error-star">*</span>:</label>
                    <?php echo $this->form->site_name; ?>
                </div>

                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_phone_1"); ?>:</label>
                    <?php echo $this->form->site_phone_1; ?>
                </div>

                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_phone_2"); ?>:</label>
                    <?php echo $this->form->site_phone_2; ?>
                </div>

                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_phone_3"); ?>:</label>
                    <?php echo $this->form->site_phone_3; ?>
                </div>

             <div class="field-box">
                 <label><?php echo $this->translate("sitemap_frm_image"); ?>:</label>
                 <?php 
                 //echo $this->imageName;exit;
                 if ($this->imageName != ""): ?>
                     <?php if (file_exists($this->UPLOAD_PATH . "site/" . $this->imageName)): ?> 
                         <?php
                         $src_path = $this->PUBLIC_PATH . "upload/site/" . $this->imageName;
                         ?>
                         <img src="<?php echo $src_path; ?>" height="200" width="200"/>&nbsp;
                          <a class="label label-add" title="View" target="_blank" href="<?php echo $this->url(array('controller' => 'site', 'action' => 'download', 'site_id' => $this->siteid), null, true);?>">
                         view </a>
                         <br>
                     <?php endif; ?>
                 <?php endif; ?>
                 <input type="file" name="site_map" id="site_map">  

             </div>
             
                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_email"); ?><span class="error-star">*</span>:</label>
                    <?php
                        echo $this->form->site_email;
                    ?>
                </div>

                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_company"); ?><span class="error-star">*</span>:</label>
                        <?php echo $this->form->com_id; ?>
                </div>
             
                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_type"); ?>:</label>
                    <div class="ui-select select_site">
                        <?php echo $this->form->type_id; ?>
                    </div>
                </div>
                
                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_address"); ?><span class="error-star">*</span>:</label>
                    <?php echo $this->form->site_address; ?>
                </div>
                
                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_city"); ?><span class="error-star">*</span>:</label>
                    <?php echo $this->form->site_city; ?>
                </div>

                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_country"); ?><span class="error-star">*</span>:</label>
                        <?php echo $this->form->site_country; ?>
                </div>

                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_zipcode"); ?>:</label>
                        <?php echo $this->form->site_postal_code; ?>
                </div>

                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_guard"); ?><span class="error-star">*</span>:</label>
                    <div class="ui-select select_site">
                        <?php echo $this->form->site_guard; ?>
                    </div>
                </div>

                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_digicode"); ?>:</label>
                        <?php echo $this->form->site_digicode; ?>
                </div>
                
                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_code"); ?>:</label>
                        <?php echo $this->form->site_code; ?>
                </div>

                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_keysafe"); ?><span class="error-star">*</span>:</label>
                    <div class="ui-select select_site">
                        <?php echo $this->form->site_keysafe; ?>
                    </div>
                </div>

                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_key_safe_loc"); ?>:</label>
                        <?php echo $this->form->site_key_safe_loc; ?>
                </div>

                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_vulnerabilities"); ?>:</label>
                    <?php echo $this->form->site_vulnerabilities; ?>
                </div>

                <div class="field-box">
                    <label><?php echo $this->translate("site_frm_status"); ?><span class="error-star">*</span>:</label>
                    <div class="ui-select select_site ">
                    <?php echo $this->form->site_status; ?>
                    </div> 
                </div>
                <br>

                
                <div class="field-box">
                    <?php echo $this->form->Save; ?>
                    <?php echo $this->form->Reset; ?> 
                </div>
           
        </div>
        
        <!-- Right Column -->
        <div class="span7">
            <h3>Hours</h3>
            <br/>
             <table class="table table-hover">
                    <thead>
                        <tr>
                            <th class="col-md-3 ">Day</th>
                            <th class ="col-md-3">Time of commissioning</th>
                            <th class ="col-md-3">Time of decommissioning</th>
                            <th class ="col-md-3">Date last action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
                         foreach ($this->weekarray as $key =>$value):
                         //echo '<pre>';
                       //  print_r($this->sitehoursData);
                        // print_r($this->weekarray);
                        if($this->mode == 'Edit' || count($this->sitehoursData)!=0): 
                          //  echo 'in';
                            if(array_key_exists($key, $this->sitehoursData)):
                                $checked = "checked";
                                $date_val = $this->sitehoursData[$key]['site_hr_date'];
                                $site_hr_commision_hr = $this->sitehoursData[$key]['site_hr_commision_hr'];
                                $site_hr_commision_mint = $this->sitehoursData[$key]['site_hr_commision_mint'];
                                $site_hr_decommision_hr = $this->sitehoursData[$key]['site_hr_decommision_hr'];
                                $site_hr_decommision_mint = $this->sitehoursData[$key]['site_hr_decommision_mint'];
                            else:
                                $checked = "";
                                $date_val = ""; 
                                $site_hr_commision_hr = "";
                                $site_hr_commision_mint = "";
                                $site_hr_decommision_hr = "";
                                $site_hr_decommision_mint = "";
                            endif;
                        else:
                             $checked = "";
                             $date_val = ""; 
                             $site_hr_commision_hr = "";
                             $site_hr_commision_mint = "";
                             $site_hr_decommision_hr = "";
                             $site_hr_decommision_mint = "";
                             
                       endif;
                         
                         
                         
                         ?>
                        <tr>
                            <td>
                                <div class="frm_left"><label for="day_chk_<?php echo $key;?>"><?php echo $value;?></label></div>
                                <div class="frm_right">
                                    <input type="checkbox" <?php echo  $checked; ?> name="site_hr_day[]" id="day_chk_<?php echo $key;?>" value="<?php echo $key;?>" >
                                </div>
                            </td>
                            <td>
                                <select name="site_hr_commision_hr[]" id="hours_<?php echo $key;?>" class="hours_cls">
                                    <?php foreach ($this->hoursarray as $hkey =>$hvalue):
                                        if($site_hr_commision_hr == $hkey){
                                           $selected = "selected";
                                        }else{
                                            $selected = "";
                                        }
                                        
                                    ?>
                                    <option value="<?php echo $hkey;?>" <?php echo $selected;?> ><?php echo $hvalue;?></option>
                                    <?php endforeach;?>
                                </select>
                                <select name="site_hr_commision_mint[]" id="minutes_<?php echo $key;?>" class="mint_cls">
                                    <?php foreach ($this->minutesarray as $mkey =>$mvalue):
                                            if($site_hr_commision_mint == $mkey){
                                               $selected1 = "selected";
                                            }else{
                                               $selected1 = "";
                                            } ?>
                                    <option value="<?php echo $mkey;?>"  <?php echo $selected1;?> ><?php echo $mvalue;?></option>
                                    <?php endforeach;?>
                                </select>
                            </td>
                            <td>
                               <select name="site_hr_decommision_hr[]" id="des_hours_<?php echo $key;?>" class="hours_cls">
                                    <?php foreach ($this->hoursarray as $hkey =>$hvalue):
                                            if($site_hr_decommision_hr == $hkey){
                                               $selected2 = "selected";
                                            }else{
                                               $selected2 = "";
                                            } 
                                     ?>
                                    <option value="<?php echo $hkey;?>"  <?php echo $selected2;?> ><?php echo $hvalue;?></option>
                                    <?php endforeach;?>
                                </select>
                                <select name="site_hr_decommision_mint[]" id="des_minutes_<?php echo $key;?>" class="mint_cls">
                                    <?php foreach ($this->minutesarray as $mkey =>$mvalue):
                                            if($site_hr_decommision_mint == $mkey){
                                               $selected3 = "selected";
                                            }else{
                                               $selected3 = "";
                                            } 
                                    ?>
                                    <option value="<?php echo $mkey;?>"  <?php echo $selected3;?>><?php echo $mvalue;?></option>
                                    <?php endforeach;?>
                                </select>
                           
                            </td>
                            <td><input class="date_last_action datepicker" value="<?php echo $date_val;?>" type="text" name="site_hr_date[]" id="date_last_action_<?php echo $key;?>"></td>
                          </tr>
                        <?php endforeach;?>
                    
                    </tbody>
             </table>
            
        </div>
    </div>
         </form>
</div>
</div>